package com.example.springaiopenaidemo.controller;


import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 张飞
 * @version 1.0
 * @since 2025-07-14
 */
@RestController("/ollama")
public class ChatController {




    private final ChatClient chatClient;

    public ChatController(ChatClient.Builder chatClient) {
        this.chatClient = chatClient.build();
    }

    @GetMapping(value="/chat")
    public String chat(@RequestParam String prompt) {
        return this.chatClient.prompt().user(prompt).call().content();
    }

}
